#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template <typename T>
inline void read(T &x)
{
    char c;
    int f = 1;
    x = 0;
    for (c = getchar(); !isdigit(c); c = getchar())
        if (c == '-')
            f = -f;
    for (; isdigit(c); c = getchar())
        x = x * 10 + (c ^ '0');
    x *= f;
}
template <typename T>
inline void chkmx(T &x, T y) { x = max(x, y); }
typedef long long ll;
int n, m;
ll L, V;
array<ll, 3> a[100020];
int p[100020];
int ans0;
int f[100020];
vector<int> vec[100020];
void FLAGIT(int l, int r)
{
    // cout << l << ' ' << r << '\n';
    if (l <= r)
        ans0++, vec[r].push_back(l - 1);
}
bool check(int id, int pos)
{
    ll d = a[id][0];
    ll v0 = a[id][1];
    ll aa = a[id][2];
    ll s = p[pos] - d;
    return v0 * v0 + 2 * aa * s > V * V;
}
void solve()
{
    ans0 = 0;
    read(n);
    read(m);
    read(L);
    read(V);
    for (int i = 1; i <= n; i++)
        read(a[i][0]), read(a[i][1]), read(a[i][2]);
    for (int i = 1; i <= m; i++)
        read(p[i]);
    for (int i = 1; i <= n; i++)
    {
        if (a[i][2] == 0)
        {
            if (a[i][1] > V)
                FLAGIT(lower_bound(p + 1, p + m + 1, a[i][0]) - p, m);
            continue;
        }
        if (a[i][2] >= 0) // chao su qu jian shi hou zhui
        {
            int q = lower_bound(p + 1, p + m + 1, a[i][0]) - p;
            int l = q, r = m, t = m + 1;
            // cout << l << ' ' << r << '\n';
            while (l <= r)
            {
                int mid = l + r >> 1;
                if (check(i, mid))
                    r = (t = mid) - 1;
                else
                    l = mid + 1;
            }
            FLAGIT(t, m);
        }
        else // qian zhui
        {
            int q = lower_bound(p + 1, p + m + 1, a[i][0]) - p;
            int l = q, r = m, t = 0;
            // cout << l << ' ' << r << '\n';
            while (l <= r)
            {
                int mid = l + r >> 1;
                if (check(i, mid))
                    l = (t = mid) + 1;
                else
                    r = mid - 1;
            }
            FLAGIT(q, t);
        }
    }
    for (int i = 0; i <= m; i++)
        f[i] = 1e9;
    f[0] = 0;
    for (int i = 1; i <= m; i++)
    {
        f[i] = f[i - 1];
        for (int j : vec[i])
            chkmx(f[i], f[j] + 1);
    }
    cout << ans0 << ' ' << m - f[m] << '\n';
    // for (int i = 0; i <= m; i++)
    //     cout << f[i] << ' ';
    // cout << '\n';
    for (int i = 0; i <= m + 1; i++)
        vec[i].clear();
}
int main()
{
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    int t;
    read(t);
    while (t--)
        solve();
    return 0;
}
// wo zen me da bu liao zhong wen???